package or;

import org.junit.jupiter.api.Test;

public class T2578 {


    public int splitNum(int num) {
        String str = new String(num + "");
        StringBuffer strb = new StringBuffer(str);
        for (int i = 0; i < strb.length() - 1; i++) {
            for (int j = i + 1; j < strb.length(); j++) {
                if (strb.charAt(i) > strb.charAt(j)) {
                    char tmp = strb.charAt(i);
                    strb.insert(i + 1, strb.charAt(j));
                    strb.deleteCharAt(i);
                    strb.insert(j + 1, tmp);
                    strb.deleteCharAt(j);
                }

            }
        }
        StringBuffer a = new StringBuffer();
        StringBuffer b = new StringBuffer();
        for (int i = 0; i < strb.length();i+=2) {
            a.append(strb.charAt(i));
            if(i+1<strb.length()){
                b.append(strb.charAt(i+1));
            }else {
                break;
            }
        }
        return Integer.parseInt(String.valueOf(a))+Integer.parseInt(String.valueOf(b));
    }

    @Test
    public void test() {

        System.out.println(splitNum(4325));


    }
}
